package errmsg

const (
	SUCCESS = 200
	ERROR   = 500

	//用户接口错误
	ERROR_USER_EXIST       = 1001
	ERROR_PASSWORD_WORNG   = 1002
	ERROR_USER_NOT_EXIST   = 1003
	ERROR_TOKEN_NOT_EXIST  = 1004
	ERROR_TOKEN_TYPE_WRONG = 1005
	ERROR_TOKEN_RUNTIME    = 1006
	ERROR_USER_NO_RIGHT    = 1007
	ERROR_USER_NO_LOGIN    = 1008

	//分类接口错误
	ERROR_CATEGORY_NOT_EXIST = 2001
	ERROR_CATEGORY_USERD     = 2002

	//文章接口错误
	ERROR_ARTICLE_NOT_EXIST = 3001
)

var codeMsg = map[int]string{
	SUCCESS:                  "OK",
	ERROR:                    "FAIL",
	ERROR_USER_EXIST:         "用户名已存在",
	ERROR_PASSWORD_WORNG:     "密码错误",
	ERROR_USER_NOT_EXIST:     "用户不存在",
	ERROR_TOKEN_NOT_EXIST:    "TOKEN不存在",
	ERROR_TOKEN_TYPE_WRONG:   "TOKEN格式错误",
	ERROR_TOKEN_RUNTIME:      "TOKEN已过期",
	ERROR_USER_NO_RIGHT:      "权限不足",
	ERROR_USER_NO_LOGIN:      "未登录",
	ERROR_CATEGORY_NOT_EXIST: "分类不存在",
	ERROR_CATEGORY_USERD:     "该分类已存在",
	ERROR_ARTICLE_NOT_EXIST:  "文章不存在",
}

func GetErrMsg(code int) string {
	return codeMsg[code]
}
